<template>
    <el-container style="min-height: 100vh">
      <el-aside width="sideWidth+'px'" style="background-color: rgb(255,255,255)"> <!--width="sideWidth+'px'"导航栏动态宽度-->
        <el-menu :default-openeds="['1', '3']" style="min-height: 100%; overflow-x: hidden"
        background-color="rgb(48,65,86)"
                 text-color="#fff"
                 active-text-color="#ffd04b"
                 :collapse-transition="false"
                 :collapse="isCollapse"
        > <!--active-text-color="#ffd04b"点击导航栏文字时候高亮黄色。  :collapse-transition="false"关闭动画（为了收缩导航栏做铺垫）
        :collapse="isCollapse"控制展开折叠
        -->
          <div style="height: 60px; line-height: 60px; text-align: center">
            <b style="color: white" v-show="logoTextShow" @click="toHome">植物医院后台管理系统</b>
          </div>
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-message"></i>
              <span slot="title">植友医师</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="1-1" @click="toPhysicianReview">医师审核</el-menu-item>
              <el-menu-item index="1-2" @click="toEncounterRecord">接诊记录</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title"><i class="el-icon-menu"></i>
              <span slot="title">植物分类</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="2-1" @click="classify">分类列表</el-menu-item>
              <el-menu-item index="2-2">选项2</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title"><i class="el-icon-user"></i>
              <span slot="title">植友用户</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="3-1" @click="toMyUser">用户信息</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="4">
            <template slot="title"><i class="el-icon-s-check"></i>
              <span slot="title">代理商</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="4-1" @click="agent">代理商入驻</el-menu-item>
              <el-menu-item index="4-2" @click="addproduct1">添加商品</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="5">
            <template slot="title"><i class="el-icon-reading"></i>
              <span slot="title">植友学院</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="5-1" @click="toCollege">学院信息</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="6">
            <template slot="title"><i class="el-icon-s-claim"></i>
              <span slot="title">商品订单</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="5-1" @click="toWhole">订单管理</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>

      <el-container>
          <el-header style="font-size: 12px;border-bottom: 1px solid #ccc; line-height: 60px;display:flex">
            <div style="flex: 1; font-size: 25px">
                  <!-- 👆收缩栏图标-->
              <span :class="collapseBtnClass" style="cursor: pointer" @click="collapse"></span>
            </div>
          <el-dropdown style="width: 100px;cursor:pointer">
            <span>王小虎</span><i class="el-icon-arrow-down" style="margin-left: 5px"></i>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>个人信息</el-dropdown-item>
              <el-dropdown-item>退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-header>
        <router-view/>
      </el-container>
    </el-container>

</template>

<script>
import addproduct from "@/views/Addproduct.vue";

export default {
  name: 'HomeView',
  computed: {
    addproduct() {
      return addproduct
    }
  },
  data() {
    const item = {
      date: '2016-05-02',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1518 弄'
    };
    return {
      tableData: Array(20).fill(item),
      collapseBtnClass:'el-icon-s-fold',
      isCollapse:false,
      sideWidth:200, //动态收缩导航栏初始值200
      logoTextShow:true,
      headerBg:'headerBg'
    }
  },
  methods:{
    toWhole(){
      this.$router.push({path:'/MyOrder'})
    },
    toSend(){
      this.$router.push({path:'/Send'})
    },
    toMyOrder(){
      this.$router.push({path:'/MyOrder'})
    },
    toCollege(){
      this.$router.push({path:'/College'})
    },
    toEncounterRecord(){
      this.$router.push({path:'/EncounterRecord'})
    },
    addproduct1(){
      this.$router.push({path:'/Addproduct'})
    },
    agent(){
      this.$router.push({path:'/Agent'})
    },
    classify(){
      this.$router.push({path:'/Classify'})
    },
    toHome(){
      this.$router.push('/')
    },
    toPhysicianReview(){
      this.$router.push('/physicianReview')
    },
    toMyUser(){
      this.$router.push('/MyUser')
    },
    collapse(){ //点击收缩按钮触发
      this.isCollapse = !this.isCollapse
      if (this.isCollapse){ //收缩
        this.sideWidth = 64
        this.collapseBtnClass='el-icon-s-unfold'
        this.logoTextShow=false
      }else {  //展开
        this.sideWidth = 200
        this.collapseBtnClass='el-icon-s-fold'
        this.logoTextShow=true
      }
    }
  }
}
</script>

<!--顶部的横栏颜色定义-->
<style>
.headerBg{
  background: #ccc !important;
}
</style>
